<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page contentType="text/html" language="java" import="com.compuvest.web.*,java.util.*" pageEncoding="UTF-8"%>

<%@ taglib uri="/WEB-INF/tld/head.tld" prefix="head" %>
<%@ taglib uri="/WEB-INF/tld/bottom.tld" prefix="bottom" %>

<jsp:useBean id="sb" class="MySQL" scope="application"/>
<jsp:useBean id="advertArray" class="AdvertArray" scope="application"/>
<jsp:useBean id="basket" class="Basket" scope="session"/>
<%
    String email = advertArray.getString(request.getParameter("Email"), "");
    String password = advertArray.getString(request.getParameter("Password"), "");
    String orderNumber = advertArray.getString(request.getParameter("Order"), "");
    String phone = advertArray.getString(request.getParameter("Phone"), "");

    java.text.DecimalFormat prf = new java.text.DecimalFormat("$###,##0.00");

    List<Order> orders = new ArrayList();

    if((!email.equals("") && !password.equals("")) || !orderNumber.equals("") || !phone.equals("")) {
	orders = sb.getTrackingOrder(email, password, orderNumber, phone);
    }
%>
<html>
<%@include file="/incl/head.html" %>

<body>

<table style='height:100%;'>

<tr valign=top height=84>
 <td colspan=3>

<head:show />

 </td>
</tr>

<tr valign=top align=center>

 <td style="width:100px;">&nbsp;</td>

 <td>

<div class=cstitle>Orders History</div><br/>
<%
    if(orders.size() != 0) {
%>
<hr/>
<table width='90%' cellspacing=1 cellpadding=1 style='background:silver;font:bold 8.3pt Arial;height:18px;'>
 <tr height=26><td colspan=9 background="../images/tbg.png">&nbsp;</td></tr>
 <tr bgcolor=lightblue><th></th><th>Order #</th><th>Date</th><th>COD</th><th>Shipping</th><th>Delivery</th><th>WA Tax</th><th>Total</th><th>Tracking #</th></tr>
<%
    boolean bground = false;
    for(Order order : orders) {
	bground = !bground;
%>
 <tr bgcolor=#ffff<%= bground ?  "cf" : "ef" %> align=center>
  <td>
<%
	if(order.haveHistory()) {
%>
  <a href='<%= application.getInitParameter("https") + "OrderPrint.jsp" %>?oid=<%= order.getOrderID() %>'>Print</a>
<%
	}
%>
  </td>
  <td><%= order.getOrderNo() %></td>
  <td><%= order.getOrderDate() %></td>
  <td><%= "Y".equals(order.getCOD()) ? "COD" : "" %></td>
  <td><%= order.getShippingCost() == 0.0 ? "" : prf.format(order.getShippingCost()) %></td>
  <td><%= order.getShippingDesc() %></td>
  <td><%= order.getTaxCost() == 0.0 ? "" : prf.format(order.getTaxCost()) %></td>
  <td><%= prf.format(order.getGrandTotal()) %></td>
  <td>
<%
	String trStatus = "";
	java.util.ArrayList<Tracking> tracks = order.getTracking();
	if(tracks.size() != 0) {
	    for(int i = 0; i < tracks.size(); i++) {
		Tracking track = tracks.get(i);
		if(i == 0) {
		    trStatus = track.getStatusLong();
		}
%>
  <%= track.getShippingCompany().length() == 0 ? "" : track.getShippingCompany() + ": " %><%= track.getStatusShort() %><br/>
<%
	    }
	}
	else {
%>
 Processing...
<%
	}
%>
  </td>
 </tr>
<%
    if(trStatus.length() != 0) {
%>
 <tr bgcolor=#ffff<%= bground ?  "cf" : "ef" %> height=40>
  <td></td>
  <td colspan=8><%= trStatus %></td>
 </tr>
<%
    }
%>
<%
    }
%>
</table>
<hr/>
<%
    }
    else {
%>
<div align=left class=messg>
 <p>Dear CompuVest Customer,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;at this time we cannot provide you with the
  tracking number for your order.</p>
 <p>This may happen for one of the following reasons:</p>
<fieldset style="background-color:white;width:95%;padding:10px 10px;">
 <ol style="list-style-type:upper-alpha;">
  <li/><b>Your order has been shipped, but the tracking number hasn't been uploaded in to the system yet.</b>
  <li/><b>Your order has not been shipped yet, because:</b>
   <ul>
    <li/> Your credit card has been declined
    <li/> Compuvest has not received your order yet
    <li/> Order was placed too late to meet the shipping deadline for that day
    <li/> Product on the order is being backordered
   </ul>
 </ol>
</fieldset>
<br/><br/>

 <p>If you need assistance, please contact us by e-mail at
  <a href="mailto:info@compuvest.com?subject=Please provide me with Tracking Number"> info@compuvest.com</a><br/>
  or by phone: <b>425.738.4091</b> so that CompuVest personal could assist you.
 </p><br/>

<fieldset style="background-color:white;width:95%;padding:5px 5px;">
<font color=red>IMPORTANT: Please include your <i><b><font color=#101852>order number</font></b></i>&nbsp; when sending shipping information inquiry.</font>
</fieldset>

<p> Thank you<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CompuVest Corp.&trade;<br/></p>

</div>
<hr width='50%'/>
<%
    }
%>
<br/>
 
 </td>

 <td style="width:100px;">&nbsp;</td>
</tr>

<tr height=35>
 <td colspan=3>

<bottom:show />

 </td>
</tr>

</table>

</body>
<%@ include file="./incl/tracking.incl" %>
</html>
